package com.chinadrtv.batch.admin.util;

import com.chinadrtv.user.model.ozing.auth.OzingUser;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.IOException;

public class OzingAuthTag extends SimpleTagSupport {
    private String url;
    private String type;

    @Override
    public void doTag() throws JspException, IOException {
        OzingUser ozingUser = (OzingUser) ((PageContext) this.getJspContext()).getSession().getAttribute(OzingUser.OZING_USER_SESSION_KEY);
        if (ozingUser != null) {
            if (ozingUser.hasAuth(url)) {
                this.getJspBody().invoke(null);
            } else {
                this.getJspContext().getOut().println("");
            }
        }
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }
}
